package com.it.App.controller;

import com.it.App.eneity.User;
import com.it.App.service.UserService;
import com.it.App.vo.Response;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author: CaoYouGen
 * @DateTime: 2023/11/28/11:14
 * @注释: TODO
 **/
@RestController
@RequestMapping("/user")
@Api(tags = "用户相关接口")
public class UserController {
    @Autowired
    private UserService userService;

    @PostMapping("/login")
    @ApiOperation("登录")
    public Response<?> login(@RequestBody User user) {
        return userService.login(user);
    }

    @ApiOperation("退出登录")
    @PostMapping("/logout")
    public Response<?>  logout() {
        SecurityUtils.getSubject().logout();
        return Response.ok("成功退出");
    }


    @GetMapping("/course")
    @ApiOperation("查看课程")
    @RequiresPermissions("course:choose")
    public Response<?> course() {
        return Response.ok("您有课程的权限,可以查看！");
    }
}
